import { singleton } from '@/utils/singleton'
const eventNames = ['STORAGE:USERINFO_CHANGE']

class EventEmitter {
    listeners = {
        'STORAGE:USERINFO_CHANGE': new Set()
    }

    on(eventName, listener) {
        this.listeners[eventName].add(listener)
    }

    emit(eventName, ...args) {
        this.listeners[eventName].forEach(listener => listener(...args))
    }
}

const EventEmitterSingleton = singleton(EventEmitter)

export default new EventEmitterSingleton()